<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Cookie;

class CheckAdmin
{
     /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $userId = Cookie::get('user_id', '');
        $authId = Cookie::get('auth', 0);
        //if ($userId === '' || $authId != Config::get('const.authAdmin')) {
        if ($userId === '') {
            return redirect('login');
        }
        return $next($request);
    }
}
